#include<stdio.h>

int isLeap(int year)
{
    if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
    {
        return 1;
    }

    return 0;
}

int main()
{
    int start, end, cnt = 0, k = 0;
    int leaps[100] = {0};
    scanf("%d %d", &start, &end);

    if(start < end)
    {
        int i; 
        for(i = start; i <= end; i++)
        {
            if(isLeap(i))
            {
                cnt++;
                leaps[k++] = i;
            }
        }
        
        for(i = 0; i < k; i++)
        {
            if(i != k - 1)
            {
                printf("%d ", leaps[i]);
            }
            else
            {
                printf("%d", leaps[i]);
            }
        }
    
        if(cnt == 0)
        {
            printf("0000");
        }
        else
        {
            printf("\n%d", cnt);
        }

    }
    else
    {
        int i; 
        for(i = start; i >= end; i--)
        {
            if(isLeap(i))
            {
                cnt++;
                leaps[k++] = i;
            }
        }
        
        for(i = 0; i < k; i++)
        {
            if(i != k - 1)
            {
                printf("%d ", leaps[i]);
            }
            else
            {
                printf("%d", leaps[i]);
            }
        }
    
        if(cnt == 0)
        {
            printf("0000");
        }
        else
        {
            printf("\n%d", cnt);
        }

    }
	
    return 0;
}
